package xcmg.device.service.vo;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * 外部接口需要校验的参数
 *
 * @author wangyong
 */
public class ExternalParamCheckVO {
    /**
     * 发运方式：
     * 0公路配载，1铁路配载，2客运配载，3快递，4航空，5专车运输，6自提，7随整机，8海运，10直发
     */
    private static final String[] DELIVERY_TYPE = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "10"};

    /**
     * 结算方式
     * 0寄付，1到付，2月付
     */
    private static final String[] SETTLE_TYPE = {"0", "1", "2"};

    /**
     * 采购级别
     * 1紧急，2补库，3月度，4三包
     */
    private static final String[] PURCHASE_LEVEL = {"1", "2", "3", "4"};

    /**
     * 库区
     */
    private String inArea;

    /**
     * 仓库
     */
    private String inLocation;

    /**
     * 调出库区
     */
    private String outArea;

    /**
     * 调出仓库
     */
    private String outLocation;

    /**
     * 企业sapCode
     */
    private String sapCode;

    /**
     * 零件编号
     */
    private List<String> materialsNos;

    /**
     * 单据类型ID
     */
    private String typeId;

    /**
     * 销售意向单号
     */
    private String saleNo;

    /**
     * 非正常入库单备件系统内部订单号
     */
    private String abnormalInNo;

    /**
     * 非正常出库单备件系统内部订单号
     */
    private String abnormalOutNo;

    /**
     * 发运方式ID
     */
    private String deliveryTypeId;

    /**
     * 结算方式ID
     */
    private String settleTypeId;

    /**
     * 采购等级ID
     */
    private String purchaseLevelId;

    public String getInArea() {
        return inArea;
    }

    public void setInArea(String inArea) {
        this.inArea = inArea;
    }

    public String getInLocation() {
        return inLocation;
    }

    public void setInLocation(String inLocation) {
        this.inLocation = inLocation;
    }

    public String getOutArea() {
        return outArea;
    }

    public void setOutArea(String outArea) {
        this.outArea = outArea;
    }

    public String getOutLocation() {
        return outLocation;
    }

    public void setOutLocation(String outLocation) {
        this.outLocation = outLocation;
    }

    public String getSapCode() {
        return sapCode;
    }

    public void setSapCode(String sapCode) {
        this.sapCode = sapCode;
    }

    public List<String> getMaterialsNos() {
        return materialsNos;
    }

    public void setMaterialsNos(List<String> materialsNos) {
        this.materialsNos = materialsNos;
    }

    public String getTypeId() {
        return typeId;
    }

    public void setTypeId(String typeId) {
        this.typeId = typeId;
    }

    public String getSaleNo() {
        return saleNo;
    }

    public void setSaleNo(String saleNo) {
        this.saleNo = saleNo;
    }

    public String getAbnormalInNo() {
        return abnormalInNo;
    }

    public void setAbnormalInNo(String abnormalInNo) {
        this.abnormalInNo = abnormalInNo;
    }

    public String getAbnormalOutNo() {
        return abnormalOutNo;
    }

    public void setAbnormalOutNo(String abnormalOutNo) {
        this.abnormalOutNo = abnormalOutNo;
    }

    public String getDeliveryTypeId() {
        return deliveryTypeId;
    }

    public void setDeliveryTypeId(String deliveryTypeId) {
        this.deliveryTypeId = deliveryTypeId;
    }

    public String getSettleTypeId() {
        return settleTypeId;
    }

    public void setSettleTypeId(String settleTypeId) {
        this.settleTypeId = settleTypeId;
    }

    public String getPurchaseLevelId() {
        return purchaseLevelId;
    }

    /**
     * 判断发货方式参数是否正确
     *
     * @return
     */
    public boolean deliveryTypeCorrect() {
        if (StringUtils.isBlank(this.deliveryTypeId)) {
            return true;
        }
        return ArrayUtils.contains(DELIVERY_TYPE, this.deliveryTypeId);
    }

    /**
     * 判断结算方式参数是否正确
     *
     * @return
     */
    public boolean settleTypeCorrect() {
        if (StringUtils.isBlank(this.settleTypeId)) {
            return true;
        }
        return ArrayUtils.contains(SETTLE_TYPE, this.settleTypeId);
    }

    /**
     * 判断采购等级参数是否正确
     *
     * @return
     */
    public boolean purchaseLevelCorrect() {
        if (StringUtils.isBlank(this.purchaseLevelId)) {
            return true;
        }
        return ArrayUtils.contains(PURCHASE_LEVEL, this.purchaseLevelId);
    }
}
